package com.ruoyi.wechat.api;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.wechat.domain.Camp;
import com.ruoyi.wechat.service.ICampService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 营地管理Controller
 * 
 * @author ruoyi
 * @date 2024-07-26
 */
@Api(value = "营地管理", tags = {"营地管理"})
@RestController
@RequestMapping("/wechat/camp")
public class WxCampController extends BaseController
{
    @Autowired
    private ICampService campService;

    /**
     * 查询营地管理列表
     */

    @ApiOperation("营地列表")
    @GetMapping("/list")
    public TableDataInfo list(Camp camp)
    {
        startPage();
        List<Camp> list = campService.selectCampList(camp);
        return getDataTable(list);
    }


    /**
     * 获取营地管理详细信息
     */
    @ApiOperation("获取营地管理详细信息")
    @GetMapping(value = "/{campId}")
    public AjaxResult getInfo(@PathVariable("campId") String campId)
    {
        return success(campService.selectCampByCampId(campId));
    }

    /**
     * 新增营地管理
     */
    @ApiOperation("新增营地")
    @Log(title = "营地管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Camp camp)
    {
        return success(campService.insertCamp(camp));
    }

    /**
     * 修改营地管理
     */
    @ApiOperation("修改营地")
    @Log(title = "营地管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Camp camp)
    {
        return toAjax(campService.updateCamp(camp));
    }

    /**
     * 删除营地管理
     */
    @ApiOperation("删除营地")
    @Log(title = "营地管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{campIds}")
    public AjaxResult remove(@PathVariable String[] campIds)
    {
        return toAjax(campService.deleteCampByCampIds(campIds));
    }

    @ApiOperation("预约营地列表")
    @GetMapping("/listAppointmentByUserId/{userId}")
    public AjaxResult listAppointmentByUserId(@PathVariable("userId")String userId){
        List<Camp> list = campService.selectCampAppointmentByUserId(userId);
        return success(list);
    }
}
